home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / MacPNG Library 1.02 / pngMacSrc 1.02 / macmain.c < prev    next >
C/C++ Source or Header  |  1996-03-11  |  3KB  |  93 lines

  1. // A cheep file prompt for selecting PGN files.
  2. //
  3. //    History
  4. //    1996/03/11    RMF Updated for PPC and set SIOUXSetting
  5. //    1995/09/05    By R. Mark Fleming <markf@post.queensu.ca>\
  6. //                Provide the basic file select to replace unix command line prompt.
  7. //
  8. #include <stdlib.h>
  9. #include <stdio.h>
  10. #include <unix.h>        // _fcreator & __ftype
  11. #include <sioux.h>
  12.  
  13. #include <Files.h>
  14. #include <LowMem.h>
  15. #include <StandardFile.h>
  16. #include <Memory.h>
  17. Boolean gDone = false;
  18.  
  19. int _Main( int argc, char *argv[]);
  20. OSErr ConvertFile(StandardFileReply *reply, char *Myargv[2]);
  21.  
  22. int main( int argc, char *argv[])
  23. {
  24. #pragma unused ( argc )
  25. #pragma unused ( argv )
  26.     StandardFileReply reply;
  27.     SFTypeList typeList;
  28.     OSErr err = noErr;
  29.     char *Myargv[2];
  30.     Str255 appName;
  31.  
  32.     
  33. /* Don’t exit the program after it runs or ask whether to save the window when the program exit */ 
  34.     SIOUXSettings.autocloseonquit = FALSE; 
  35.     SIOUXSettings.asktosaveonclose = FALSE;
  36. /* Don’t show the status line */ 
  37.     SIOUXSettings.showstatusline = FALSE;
  38. /* Make the window large enough to fit 1 line of text that contains 12 characters. */
  39.     SIOUXSettings.columns = 80; SIOUXSettings.rows = 24;
  40.     SIOUXSettings.toppixel = 40; SIOUXSettings.leftpixel = 5;
  41.     SIOUXSettings.tabspaces = 4;
  42.     
  43.     SIOUXSettings.autocloseonquit = TRUE; 
  44.     SIOUXSettings.asktosaveonclose = TRUE;
  45.     
  46.     SIOUXSettings.standalone = FALSE; 
  47.     SIOUXSettings.setupmenus = TRUE; 
  48.     
  49.     /* When you want to initialize the Macintosh Toolbox yourself, set the field initializeTB to FALSE. */
  50.     SIOUXSettings.initializeTB = TRUE;
  51.     
  52.     BlockMoveData((Ptr)LMGetCurApName(), (Ptr)appName, sizeof(Str31));    // Get the current application name
  53.     p2cstr(appName);
  54.     Myargv[0] = (char *) &appName[0];                                    // Arg[0] = application name
  55.     Myargv[1] = (char *)reply.sfFile.name;                                // Arg[1] = the file to translate
  56.     
  57.     fprintf(stderr, "%s V1.0, Freeware, convert to Macintosh\r\nby Mark Fleming <Markf@post.queensu.ca>\r\n", appName);
  58.     fprintf(stderr, "\r\nfor updates check out:\n\r\t<http://ccsmacinfo.ccs.queensu.ca/Mark/>\n");
  59.  
  60.  
  61.     StandardGetFile(nil, -1,    typeList, &reply);
  62.     while (reply.sfGood && err == noErr) {
  63.         err = ConvertFile(&reply, Myargv);            
  64.         if (err != noErr)    SysBeep(0);    /* End if Err */
  65.             
  66.         StandardGetFile(nil, -1,    typeList, &reply);
  67.         }    // End while()
  68.     
  69.     return err;
  70. }    /* End of () */
  71.  
  72. OSErr ConvertFile(StandardFileReply *reply, char *Myargv[2])
  73. {    OSErr err;
  74.     short savedVol;
  75.     
  76.     err = GetVol(0, &savedVol);
  77.     if (err == noErr) {
  78.         err = HSetVol(0, reply->sfFile.vRefNum, reply->sfFile.parID);
  79.         if (err == noErr) {
  80.             p2cstr(reply->sfFile.name);
  81.             
  82.             fprintf(stderr, "\r\nProcessing file: %s\r\n", Myargv[1]);
  83.  
  84.             _Main(2, Myargv);
  85.             
  86.             c2pstr((char*)reply->sfFile.name);
  87.         }
  88.         SetVol(0, savedVol);
  89.     }
  90.     return err;
  91. }    // end of ConvertFile()
  92.  
  93.